package com.lanxiao.cloud.modules.oauth.controller;

import com.lanxiao.cloud.common.core.enums.OperationType;
import com.lanxiao.cloud.common.web.invalid.Log;
import com.lanxiao.cloud.modules.oauth.application.OauthCmdManager;
import com.lanxiao.cloud.modules.oauth.application.dto.RegisterCmd;
import com.lanxiao.cloud.modules.oauth.application.dto.UserAuthPwdCmdUpdate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：qiaoliang
 * @date ：2021-09-14
 */
@Api(tags = "注册")
@Validated
@RequestMapping("/oauths")
@RestController
public class RegisterController {

  private final OauthCmdManager oauthCmdManager;

  public RegisterController(
      OauthCmdManager oauthCmdManager) {
    this.oauthCmdManager = oauthCmdManager;
  }

  @ApiOperation(value = "注册")
  @Log(operationType = OperationType.REGISTER)
  @PostMapping("/register")
  public ResponseEntity<String> register(@Valid @RequestBody RegisterCmd registerCmd) {
    oauthCmdManager.register(registerCmd);
    return ResponseEntity.status(HttpStatus.CREATED).build();
  }


}
